﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using DevExpress.XtraTreeList.Nodes;

namespace ESOL.Controls
{
    public partial class DevTreeList : DevExpress.XtraTreeList.TreeList
    {
        public DevTreeList()
        {
            InitializeComponent();
            this.NodeChanged += new DevExpress.XtraTreeList.NodeChangedEventHandler(DevTreeList_NodeChanged);
        }

        private void DevTreeList_NodeChanged(object sender, DevExpress.XtraTreeList.NodeChangedEventArgs e)
        {
            SetNodeCheckStatus(e.Node, e.Node.Checked);
        }

        protected virtual void SetNodeCheckStatus(TreeListNode tn, bool Checked)
        {
            if (tn == null) return;
            foreach (TreeListNode tnChild in tn.Nodes)
            {
                tnChild.Checked = Checked;
                SetNodeCheckStatus(tnChild, Checked);

            }
            TreeListNode tnParent = tn;
        }

        public DevTreeList(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
            this.NodeChanged += new DevExpress.XtraTreeList.NodeChangedEventHandler(DevTreeList_NodeChanged);
        }

    }
}
